﻿
Public Interface IApi
    ReadOnly Property Action As String
    ''' <summary>
    ''' 自定义结果
    ''' </summary>
    ''' <param name="Result"></param>
    ''' <param name="Data"></param>
    ''' <param name="Log"></param>
    ''' <returns></returns>
    Function Deal(Result As Integer, Data As String, Log As LogSub) As TryResult
    ''' <summary>
    ''' 成功
    ''' </summary>
    ''' <param name="Result"></param>
    ''' <param name="Data"></param>
    ''' <param name="Log"></param>
    ''' <returns></returns>
    Function DealSuccess(Result As Integer, Data As String, Log As LogSub) As TryResult
    ''' <summary>
    ''' 失败
    ''' </summary>
    ''' <param name="Result"></param>
    ''' <param name="Data"></param>
    ''' <param name="Log"></param>
    ''' <returns></returns>
    Function DealFail(Result As StateCode, Data As String, Log As LogSub) As TryResult
End Interface
Public MustInherit Class AbsApi
    Implements IApi
    Public MustOverride ReadOnly Property Action As String Implements IApi.Action
    Public MustOverride Function Deal(Result As Integer, Data As String, Log As LogSub) As TryResult Implements IApi.Deal
    Public Overridable Function DealSuccess(Result As Integer, Data As String, Log As LogSub) As TryResult Implements IApi.DealSuccess
        Return TryResult.Success
    End Function
    Public Overridable Function DealFail(Result As StateCode, Data As String, Log As LogSub) As TryResult Implements IApi.DealFail
        If Result = StateCode.Parameter Then
            If Not String.IsNullOrWhiteSpace(Data) Then Log($"{Result.GetDescription()}==>{Data}")
        Else
            Log(Result.GetDescription())
        End If
        Return TryResult.Fail
    End Function
End Class